<?php
class Control_ActivityConf_preview {
	function preview() {
		$node_id = MooForm::request('node_id');
		$type	 = MooForm::request('type');
		
		$nodeObj = MooDao::get('Node')->load($node_id);
		if(!$nodeObj) {
			exit("该文件不存在");
		}
		
		$excelPath = $nodeObj->node_path;
		$excelName = $nodeObj->excel_name;
		$xmlPath = $nodeObj->xml_path;
		$luaPath = $nodeObj->lua_path;
		
		$urlHead = MooConfig::get('main.downUrlHead');
		if($type == "excel") {
			// 预览 excel
			MooObj::get('Control_ExcelConfMaker_Excel')->preview($excelPath, $excelName);
		} else if ($type == "xml") {
			// 预览xml
			if(!$urlHead) {
				exit("urlHead 不存在");
			}
			
			$xmlPath = str_ireplace(ROOT_PATH, "", $xmlPath);
			$url = $urlHead . $xmlPath;
			
			MooUtil::redirect($url);
		} else if  ($type == "lua") {
			if(!$urlHead) {
				exit("urlHead 不存在");
			}
			
			$luaPath = str_ireplace(ROOT_PATH, "", $luaPath);
			$url = $urlHead . $luaPath;
			$url = str_ireplace("\\", "/", $url);
			
			MooUtil::redirect($url);
		}
	}
}